package com.dwm716.shorturl.controller;

import com.dwm716.shorturl.domain.User;
import com.dwm716.shorturl.service.UserService;
import com.dwm716.shorturl.utils.RoleEnum;

import javax.annotation.Resource;
import java.util.Objects;

/**
 * Created by wilson on 2025/2/1.
 */
public class BaseController {

    @Resource
    protected UserService userService;

    public boolean isLoginUser(Integer userId) {
        if (Objects.isNull(userId)) {
            return false;
        }
        User user = userService.getById(userId);
        return Objects.nonNull(user);
    }

    public boolean isSupperAdminUser(Integer userId) {
        if (Objects.isNull(userId)) {
            return false;
        }
        User user = userService.getById(userId);
        return Objects.nonNull(user) && Objects.equals(user.getRole(), RoleEnum.SupperManager.name());
    }


}
